package com.example.obs.dao;

import com.example.obs.model.domin.ObsFile;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface FileMapper {
    List<ObsFile> selectFileListByPath(@Param("userId") Integer userId, @Param("path") String path,@Param("fileState") Integer fileState,@Param("type") String type);
    List<ObsFile> selectFileListByType(@Param("userId") Integer userId,@Param("type") String type);
    List<ObsFile> selectFileListByNameAndPath(@Param("userId") Integer userId,@Param("name") String name,@Param("path") String path);
    List<ObsFile> selectFileListByState(@Param("userId") Integer userId,@Param("fileState") Integer fileState);
    ObsFile getFileByPath(@Param("userId") Integer userId,@Param("path") String path);
    ObsFile getFileByFileId(Integer id);
    void addFile(ObsFile file);
    void deleteFile(Integer id);
    void deleteDir(@Param("userId") Integer userId,@Param("path") String path);
    void updateFileName(@Param("id") Integer id,@Param("newPath") String newPath,@Param("newName") String newName);
    void updateFilePath(@Param("id") Integer id,@Param("newPath") String newPath);
    void updateFileState(@Param("id") Integer id,@Param("fileState") Integer fileState);
    void updateDirState(@Param("userId") Integer id,@Param("path") String path,@Param("fileState") Integer fileState);
    List<ObsFile> selectDocumentsList(@Param("userId") Integer id, @Param("types") String[] types);
    List<ObsFile> DocumentsList(@Param("userId") Integer id, @Param("types") String[] types);

    /**
     * 根据目录和部门id查询权限
     * @param paths 目录集合
     * @param departmentId 部门id
     * @param direction 是否为文件夹
     * @return 权限
     **/
    Integer selectPermissionByPathAndDepartment(@Param("paths") List<String> paths, @Param("department") Integer departmentId, @Param("direction") Boolean direction);

}
